
global user "diegove"
global dirdata "C:\Users\\$user\Dropbox\CCT BJP\data"
global dir1  "$dirdata\Final data"
global dir2  "$dirdata\Results\graphs"
global dir3  "$dirdata\Results\"
cd "$dir2"

use "$dir1\pooled_hh.dta", clear
keep if tau>-5  
g age=age_m if hhmale==0
replace age=age_p if hhmale==1
g spanish=spanish_m if hhmale==0
replace spanish=spanish_p if hhmale==1

g Post=tau>=0

global covs1 "age_m spanish_m schooling_m age spanish schooling hhmale urban np nchild5 age_sac  c.age_sac#i.year c.np#i.year  i.departamento#i.year i.year i.departamento"
global covs2 "age spanish  schooling age_p spanish_p schooling_p hhmale urban np nchild5 age_sac  c.age_sac#i.year c.np#i.year i.departamento#i.year  i.year i.departamento"
 
local spec1  Post i.min_schooling  $covs1  
local spec2  Post i.min_schooling  $covs2  

local sample1 "(min_schooling>=1 & min_schooling<9)"

g coef=.
g lb=.
g ub=.
g x=.


preserve
forval x=10(10)90 {
bootstrap, cluster(municipio) reps(500) seed(2) : rifhdreg hoursw_p `spec1'  if `sample1', rif(q(`x'))   cluster(municipio)
matrix CI=e(ci_bc)
replace coef=_b[Post] in `x'
replace lb=CI[1,1] in `x'
replace ub=CI[2,1] in `x'
replace x=`x' in `x'
}

keep coef lb ub x  
sort x
drop if coef==.

tw scatter coef x, sort || rcap ub lb x, sort    yline(0)   ytitle(Hours, size(small)) legend(order(1 "Effect" 2 "95% CI" )  size(small)) xtitle(Percentile) title("QTE-Males", size(msmall)) saving(a1, replace) graphregion(color(white)) ylabel(,labsize(small)) xlabel(#10, labsize(small))
graph export qtemales.eps, replace
restore


